package com.upay.android.client.validation;

import static com.upay.android.client.helper.Keys.PASSWORD_VALIDATION;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PasswordValidator {
	
	/* ---- Constants ---- */

    private static final String PASSWORD_PATTERN = "^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\\d]).*$";

    /* ---- Instance Variables ---- */
    private Pattern pattern;
    private Matcher matcher;

    /* ---- Constructors ---- */
    public PasswordValidator() {
        pattern = Pattern.compile(PASSWORD_PATTERN);
    }

	/* ---- Business Methods ---- */

	public void validate(String password, Map<String, String> errors) {
			
		matcher = pattern.matcher(password);
        if (!matcher.matches()) {
        	errors.put(PASSWORD_VALIDATION, "Invalid password");
        }
		
	}    
    /* ---- Getters and Setters ---- */


}
